package doudizhu1;

import java.util.ArrayList;
import java.util.Collections;

public class PokerGame {
    //1.准备牌
    //1.1创建集合（牌盒）
    static ArrayList<String> list=new ArrayList<>();
    //1.2加载牌
    static {
        String[] colour={"♥","♠","♣","♦"};
        String[] number={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        for (String c : colour) {
            for (String n : number) {
                list.add(c+n);
            }
        }
        list.add("小王");
        list.add("大王");
    }
    //2.洗牌
    PokerGame(){
        Collections.shuffle(list);
//        System.out.println(list);
//        System.out.println(list.size());
    //3.发牌
    //3.1创建4个集合，接收牌
    ArrayList<String> lord=new ArrayList<>();
    ArrayList<String> player1=new ArrayList<>();
    ArrayList<String> player2=new ArrayList<>();
    ArrayList<String> player3=new ArrayList<>();
    //3.2遍历牌，发给每个人
        for (int i = 0; i < list.size(); i++) {
            String poker=list.get(i);
            if(i<=2){
                lord.add(poker);
                continue;
            }
            if(i%3==0){
                player1.add(poker);
            }
            else if(i%3==1){
                player2.add(poker);
            }
            else{
                player3.add(poker);
            }
        }

    //4.看牌
        showpoker("地主牌",lord);
        showpoker("player1",player1);
        showpoker("player2",player2);
        showpoker("player3",player3);


    }
    public void showpoker(String name,ArrayList<String> list){
        System.out.print(name+" : ");
        for (String s : list) {
            System.out.print(s+" ");
        }
        System.out.println();
    }

}
